<template>
  <div class="mod-card__dealer">
    <el-form :inline="true" :model="state.dataForm" @keyup.enter="state.getDataList()">
      <el-form-item>
        <el-button @click="state.getDataList()">{{ $t("query") }}</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="state.dataListLoading" :data="state.dataList" border @selection-change="state.dataListSelectionChangeHandle" style="width: 100%">
      <el-table-column prop="name" :label="$t('gate.name')" header-align="center" align="center"></el-table-column>
      <el-table-column prop="personType" :label="$t('gate.personType')" header-align="center" align="center">
        <template v-slot="scope">
          <span>{{ PersonTypeNames[scope.row.personType] }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="className" :label="$t('gate.className')" header-align="center" align="center"></el-table-column>
      <el-table-column prop="deviceId" :label="$t('gate.deviceId')" header-align="center" align="center"></el-table-column>
      <el-table-column prop="deviceLocation" :label="$t('gate.deviceLocation')" header-align="center" align="center"></el-table-column>
      <el-table-column prop="devicePurpose" :label="$t('gate.devicePurpose')" header-align="center" align="center">
        <template v-slot="scope">
          <span>{{ DevicePurposeNames[scope.row.devicePurpose] }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="authentication" :label="$t('gate.authentication')" header-align="center" align="center">
        <template v-slot="scope">
          <span>{{ AuthenticationNames[scope.row.authentication] }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="time" :label="$t('gate.time')" header-align="center" align="center"></el-table-column>
      <el-table-column prop="imageUrl" :label="$t('gate.imageUrl')" header-align="center" align="center">
        <template v-slot="scope">
          <el-image style="width: 80px; height: 80px" :src="scope.row.imageUrl" :preview-src-list="[scope.row.imageUrl]" fit="contain"></el-image>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="state.page" :page-sizes="[10, 20, 50, 100]" :page-size="state.limit" :total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="state.pageSizeChangeHandle" @current-change="state.pageCurrentChangeHandle"> </el-pagination>
  </div>
</template>

<script lang="ts" setup>
import useView from "@/hooks/useView";
import { reactive, ref, toRefs } from "vue";
import { AuthenticationNames, DevicePurposeNames, PersonTypeNames } from './contant';

const view = reactive({
  getDataListURL: "/gate/record/page",
  getDataListIsPage: true,
  deleteURL: "/gate/record",
  deleteIsBatch: true,
  dataForm: {}
});

const state = reactive({ ...useView(view), ...toRefs(view) });
</script>
